<template>
	<view class="wrap bg-fff">
        <up-steps :current="current" dot activeColor="#007235">
            <up-steps-item :title="item.name" v-for="(item, index) in numList" :key="index">
            </up-steps-item>
        </up-steps>
        
        <view class="statusTxt col-theme fontBold">
            {{statusMsg}}
        </view>
        <block v-if="adviserStatus == 2">
            <button class="defaultBtn font13" type="default" @click="toAdviserForm">返回修改</button>
        </block>
        <block v-else>
            <button class="defaultBtn font13" type="default" @click="toAdviserHome">返回个人中心</button>
        </block>
        
        <!-- <view class="flex font12 top-15 col-grey" @click="showQrcode = true" v-if="kefuQrcode">
            <u-icon name="question-circle" color="#8A8A8A" size="14"></u-icon>
        </view> -->
        
        <up-modal :show="showQrcode" :showCloseBtn="false" :showConfirmButton="false" :closeOnClickOverlay="true" @close="showQrcode = false" @confirm="showQrcode = false">
            <dialog-qrcode :groupQrcode="false" :qrcode="kefuQrcode"></dialog-qrcode>
        </up-modal>
	</view>
</template>

<script>
import { mapState } from 'pinia';
import { useIndexStore, useUserInfoStore, useConfigStore } from '@/store/index';
import { adviserExamine } from '@/common/api';
export default {
	data() {
		return {
            adviserId: '',
            current: 1,
            adviserStatus: 0,
            statusMsg: '',
            doSubWXUrl: '',
            numList: [{
                    name: '已提交'
                }, {
                    name: '审核中'
                }, {
                    name: '审核成功'
                }
            ],
            showQrcode: false,
            kefuQrcode: ''
		};
	},
    computed: {
        ...mapState(useIndexStore, ['nowCityCode']),
        ...mapState(useUserInfoStore, ['userInfo']),
        ...mapState(useConfigStore, ['puid'])
    },
    onLoad() {
        let that = this
        uni.$check_and_login(function(){
            that.init();
        })
    },
    //分享
    onShareAppMessage(res) {
    	return {
    		title: '邀您入驻顾问之家',
    		path: `/pages/my/adviser/adviser-join?cityCode=${this.nowCityCode}`,
    	}
    },
	methods: {
        init(){
            adviserExamine().then(res => {
                const that = this;
                //置业顾问状态  0:审核中  1:审核成功 2:审核失败 3:从未申请
                if(res.status == 0) {
                    let { check, sid, mp_xpkf, qrcode } = res.detail;
                    this.adviserStatus = check;
                    this.adviserId = sid;
                    this.doSubWXUrl = mp_xpkf;
                    this.kefuQrcode = qrcode;
                    //显示订阅服务号
                    if(!this.userInfo.wx_subscribe && mp_xpkf) {
                        uni.showModal({
                        	title: '提示',
                        	content: '请关注服务号，审核状态、消息留言、问答等第一时间通知您',
                        	success: function (res) {
                        		if (res.confirm) {
                                    that.doSubscribeWX();
                        		}
                        	}
                        });
                    }
                    switch(res.detail.check){
                        case 0:
                            this.current = 1;
                        break;
                        case 1:
                            this.current = 2;
                        break;
                        case 2:
                            this.current = 2;
                            this.numList[2].name = '审核失败';
                            this.statusMsg = res.detail.msg;
                        break;
                    }
                }
            })
        },
        
        //关注微信服务号
        doSubscribeWX() {
            let url = encodeURIComponent(this.doSubWXUrl);
            uni.navigateTo({
            	url: `/pages/project/article/detail/index?url=${url}&puid=${this.puid}&title=关注服务号&prepage=置业顾问审核状态`
            })
        },
        
        //修改入驻信息
        toAdviserForm(){
            uni.navigateTo({
            	url: `/pages/my/adviser/adviser-form?adviserId=${this.adviserId}`
            })
        },
        
        //跳转顾问首页
        toAdviserHome(){
            uni.switchTab({
                url: '/pages/tabBar/my/index'
            })
        }
	}
}
</script>

<style scoped lang="scss">
.wrap{
    overflow: hidden;
    padding-top: 10vh;
    min-height: 100vh;
    .statusTxt{
        text-align: center;
        padding: 30rpx;
        margin-top: 30rpx;
    }
    .defaultBtn{
        margin: 50rpx 30rpx 0rpx 30rpx;
        background-color: $theme-color;
        color: #FFFFFF;
    }
}
</style>
